package 面试.遍历算法;

public class 冒泡排序 {
    //从数组的每一个位置都遍历到尾一次，前一个数大于后一个数则交换。升序
    public static void main(String[] args) {
        int[] arr = {7,4,3,9,6,5,3,4,21,23,52,12,86,23,34,15,25,16,867,92,82,223,123,556,234,12356,21312,643,12312,645,32421,12334,324,21,34,153,123312,42342};
        long start = System.currentTimeMillis();
        for (int i= arr.length-1;  i > 0; i--) {
            for (int g=0;g < i; g++ ){
                if (arr[g]>arr[g+1]) {
                    int aft = arr[g+1];
                    arr[g+1] = arr[g];
                    arr[g] = aft;
                }
            }


        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
        for (int i : arr) {
            System.out.print(i + ",");
        }
    }
}
